cd "yourdirectoryhere"

use "AppendixANES_2020.dta"

**variable set up 

gen abortion_dir=V201336

replace abortion_dir=. if abortion_dir<1

replace abortion_dir=. if abortion_dir==5

gen abortion_imp=V201337

replace abortion_imp=. if abortion_imp<0

gen abort_scale=abortion_dir+abortion_imp

gen abort_sc=V201340

replace abort_sc=. if abort_sc<0

replace abort_sc=0 if abort_sc!=1


gen female=0
replace female=1 if V201600==2

gen cb_fem=0
replace cb_fem=1 if female==1 & V201507x>15 & V201507x<40

gen BA_deg=0
replace BA_deg=1 if  V201510>5

*median family income was 79,560 in 2020 https://fred.stlouisfed.org/series/MEHOINUSA672N
*top quartile around 100k https://www.cbo.gov/publication/59757

gen top_quart=0
replace top_quart=1 if V201617x>17


***analysis 

svyset [pweight=V200010b], strata(V200010d) singleunit(certainty) psu(V200010c)


svy: mean abortion_dir, over(female)
svy: mean abortion_imp, over(female)

svy: mean abortion_dir, over(cb_fem)
svy: mean abortion_imp, over(cb_fem)

svy: mean abortion_dir, over(BA_deg)
svy: mean abortion_imp, over(BA_deg)

svy: mean abortion_dir, over(top_quart)
svy: mean abortion_imp, over(top_quart)

graph bar abortion_dir [pw = V200010b], over(female) 

graph bar abortion_imp [pw = V200010b], over(female)


save "anes_2020.dta", replace 

clear
